﻿/*========================== 
 * @author 郑金泉
 * @desc 数据查询接口
 * ========================= */
using System;
using System.Collections.Generic;
using System.Text;

using Obsidian.Edm;

namespace Obsidian.Data.Sql
{
    /// <summary>
    /// 数据库查询接口
    /// </summary>
    public interface IDbHandler
    {


        #region 设置字段

        /// <summary>
        /// 设置字段
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        DbHandler SetField(IModelField field);

        /// <summary>
        /// 设置字段
        /// </summary>
        /// <param name="field"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        DbHandler SetField(IModelField field, object value);

        /// <summary>
        /// 设置字段
        /// </summary>
        /// <param name="fields"></param>
        /// <returns></returns>
        DbHandler SetFields(params IModelField[] fields);

        /// <summary>
        /// 设置字段
        /// </summary>
        /// <returns></returns>
        DbHandler SetField(IModelField field, object value, OperType operType);

        #endregion

        #region Join

        JoinClause Join(IModel model);

        JoinClause LeftOuterJoin(IModel model);

        JoinClause RightOuterJoin(IModel model);

        #endregion

        IDbHandler OrderBy(IModelField field);

        IDbHandler OrderBy(IModelField field, OrderType type);

        CompoundCondition Where(ISqlCondition condition);

        DataReader Select();

        DataReader Select(QueryInfo qry);

        DataReader Select(QueryInfo qry, out ListAttrInfo listAttr);

        int SelectItemsCount();
        int SelectItemsCount(QueryInfo qry);
        int SelectItemsCount(QueryInfo qry, out ListAttrInfo listAttr);

        bool SelectFirstTo(params IModel[] model);

        object Insert();

        int Update();

        int Delete();

    }
}
